dat <- read.csv("../result/wgt_x.csv")
wx = dat$w_ols[dat$x>0]
sx = dat$w_ols_se[dat$x>0]
wz = dat$w_iv[dat$x>0]
sz = dat$w_iv_se[dat$x>0]

hx = wx + sx
lx = wx - sx
hz = wz + sz
lz = wz - sz

uni = 0.1
high <- max( max(wx),max(hz) )
high <- ceiling(high/uni)*uni
low  <- min( min(wx),min(lz) ) 
low <- floor(low/uni)*uni
high= 0.30
low = -0.10
scales= round( seq(low,high,by=uni),digits=2 )
eps = 0.1
eta = 0.25

xx = 1:18
#xone = -1:19
#yone = rep(1,times=21)
xl = c(0,20)
yl = c(low,high)
pdf('../result/wgt_cl.pdf')
par(mar=c(6.1,5.3,2.1,2.1),mgp=c(4.5,1,0),las=1)
plot(xx,wz,type="o",lwd=1.5,cex=1.75,lty=2,pch=16,col='#e31a1c',ylim=yl,xlim=xl,xlab="",ylab="",cex.axis=1.6,cex.lab=2.0,xaxt='n',yaxt='n')
par(new=T,las=1)
plot(xx,wx,type="o",lwd=1.5,cex=1.75,lty=2,pch=17,ylim=yl,xlim=xl,xlab="Years of education",ylab="",cex.axis=1.6,cex.lab=2.0,xaxt='n',yaxt='n')
par(new=T,las=1)
segments(xx,lz,xx,hz,lwd=1.5,col='#e31a1c')
segments(xx-eps,lz,xx+eps,lz,lwd=1.5,col='#e31a1c')
segments(xx-eps,hz,xx+eps,hz,lwd=1.5,col='#e31a1c')
par(new=T,las=1)
abline(h=0,lty=3,lwd=3.0)
par(new=T,las=1)
#abline(v=8,lty=3,lwd=3.0) # primary school completion (7->8)
#par(new=T,las=1)
#abline(v=12,lty=3,lwd=3.0) # high school completion (11->12)
#par(new=T,las=1)
#abline(v=16,lty=3,lwd=3.0) # college completion (15->16)
#par(new=T,las=1)
axis(1, at=c(0,4,8,12,16,20), cex.axis=1.6)
axis(2, at=scales, cex.axis=1.6, lab=format(scales,nsmall=0) )
dev.off()

dat <- read.csv("../result/wgt_x_ca.csv")
wx = dat$w_ols[dat$x>0]
sx = dat$w_ols_se[dat$x>0]
wz = dat$w_iv[dat$x>0]
sz = dat$w_iv_se[dat$x>0]

hx = wx + sx
lx = wx - sx
hz = wz + sz
lz = wz - sz

uni = 0.1
high <- max( max(wx),max(hz) )
high <- ceiling(high/uni)*uni
low  <- min( min(wx),min(lz) ) 
low <- floor(low/uni)*uni
high= 0.3
low = -0.1
scales= round( seq(low,high,by=uni),digits=2 )
eps = 0.1
eta = 0.25

xx = 1:18
#xone = -1:19
#yone = rep(1,times=21)
xl = c(0,20)
yl = c(low,high)
pdf('../result/wgt_ca.pdf')
par(mar=c(6.1,5.3,2.1,2.1),mgp=c(4.5,1,0),las=1)
plot(xx,wz,type="o",lwd=1.5,cex=1.75,lty=2,pch=16,col='#e31a1c',ylim=yl,xlim=xl,xlab="",ylab="",cex.axis=1.6,cex.lab=2.0,xaxt='n',yaxt='n')
par(new=T,las=1)
plot(xx,wx,type="o",lwd=1.5,cex=1.75,lty=2,pch=17,ylim=yl,xlim=xl,xlab="Years of education",ylab="",cex.axis=1.6,cex.lab=2.0,xaxt='n',yaxt='n')
par(new=T,las=1)
segments(xx,lz,xx,hz,lwd=1.5,col='#e31a1c')
segments(xx-eps,lz,xx+eps,lz,lwd=1.5,col='#e31a1c')
segments(xx-eps,hz,xx+eps,hz,lwd=1.5,col='#e31a1c')
par(new=T,las=1)
abline(h=0,lty=3,lwd=3.0)
par(new=T,las=1)
#abline(v=8,lty=3,lwd=3.0) # primary school completion (7->8)
#par(new=T,las=1)
#abline(v=12,lty=3,lwd=3.0) # high school completion (11->12)
#par(new=T,las=1)
#abline(v=16,lty=3,lwd=3.0) # college completion (15->16)
#par(new=T,las=1)
axis(1, at=c(0,4,8,12,16,20), cex.axis=1.6)
axis(2, at=scales, cex.axis=1.6, lab=format(scales,nsmall=0) )
dev.off()

dat <- read.csv("../result/wgt_x_rs.csv")
wx = dat$w_ols[dat$x>0]
sx = dat$w_ols_se[dat$x>0]
wz = dat$w_iv[dat$x>0]
sz = dat$w_iv_se[dat$x>0]

hx = wx + sx
lx = wx - sx
hz = wz + sz
lz = wz - sz

uni = 0.1
high <- max( max(wx),max(hz) )
high <- ceiling(high/uni)*uni
low  <- min( min(wx),min(lz) ) 
low <- floor(low/uni)*uni
high= 0.3
low = -0.1
scales= round( seq(low,high,by=uni),digits=2 )
eps = 0.1
eta = 0.25

xx = 1:18
#xone = -1:19
#yone = rep(1,times=21)
xl = c(0,20)
yl = c(low,high)
pdf('../result/wgt_rs.pdf')
par(mar=c(6.1,5.3,2.1,2.1),mgp=c(4.5,1,0),las=1)
plot(xx,wz,type="o",lwd=1.5,cex=1.75,lty=2,pch=16,col='#e31a1c',ylim=yl,xlim=xl,xlab="",ylab="",cex.axis=1.6,cex.lab=2.0,xaxt='n',yaxt='n')
par(new=T,las=1)
plot(xx,wx,type="o",lwd=1.5,cex=1.75,lty=2,pch=17,ylim=yl,xlim=xl,xlab="Years of education",ylab="",cex.axis=1.6,cex.lab=2.0,xaxt='n',yaxt='n')
par(new=T,las=1)
segments(xx,lz,xx,hz,lwd=1.5,col='#e31a1c')
segments(xx-eps,lz,xx+eps,lz,lwd=1.5,col='#e31a1c')
segments(xx-eps,hz,xx+eps,hz,lwd=1.5,col='#e31a1c')
par(new=T,las=1)
abline(h=0,lty=3,lwd=3.0)
par(new=T,las=1)
#abline(v=8,lty=3,lwd=3.0) # primary school completion (7->8)
#par(new=T,las=1)
#abline(v=12,lty=3,lwd=3.0) # high school completion (11->12)
#par(new=T,las=1)
#abline(v=16,lty=3,lwd=3.0) # college completion (15->16)
#par(new=T,las=1)
axis(1, at=c(0,4,8,12,16,20), cex.axis=1.6)
axis(2, at=scales, cex.axis=1.6, lab=format(scales,nsmall=0) )
dev.off()

dat <- read.csv("../result/wgt_x_qob.csv")
wx = dat$w_ols[dat$x>0]
sx = dat$w_ols_se[dat$x>0]
wz = dat$w_iv[dat$x>0]
sz = dat$w_iv_se[dat$x>0]

hx = wx + sx
lx = wx - sx
hz = wz + sz
lz = wz - sz

uni = 0.04
high <- max( max(wx),max(hz) )
high <- ceiling(high/uni)*uni
low  <- min( min(wx),min(lz) ) 
low <- floor(low/uni)*uni
high= 0.16
low = 0.00
scales= round( seq(low,high,by=uni),digits=2 )
eps = 0.1
eta = 0.25

xx = 1:18
#xone = -1:19
#yone = rep(1,times=21)
xl = c(0,20)
yl = c(low,high)
pdf('../result/wgt_qob.pdf')
par(mar=c(6.1,5.3,2.1,2.1),mgp=c(4.5,1,0),las=1)
plot(xx,wz,type="o",lwd=1.5,cex=1.75,lty=2,pch=16,col='#e31a1c',ylim=yl,xlim=xl,xlab="",ylab="",cex.axis=1.6,cex.lab=2.0,xaxt='n',yaxt='n')
par(new=T,las=1)
plot(xx,wx,type="o",lwd=1.5,cex=1.75,lty=2,pch=17,ylim=yl,xlim=xl,xlab="Years of education",ylab="",cex.axis=1.6,cex.lab=2.0,xaxt='n',yaxt='n')
par(new=T,las=1)
segments(xx,lz,xx,hz,lwd=1.5,col='#e31a1c')
segments(xx-eps,lz,xx+eps,lz,lwd=1.5,col='#e31a1c')
segments(xx-eps,hz,xx+eps,hz,lwd=1.5,col='#e31a1c')
par(new=T,las=1)
abline(h=0,lty=3,lwd=3.0)
par(new=T,las=1)
#abline(v=8,lty=3,lwd=3.0) # primary school completion (7->8)
#par(new=T,las=1)
#abline(v=12,lty=3,lwd=3.0) # high school completion (11->12)
#par(new=T,las=1)
#abline(v=16,lty=3,lwd=3.0) # college completion (15->16)
#par(new=T,las=1)
axis(1, at=c(0,4,8,12,16,20), cex.axis=1.6)
axis(2, at=scales, cex.axis=1.6, lab=format(scales,nsmall=0) )
dev.off()

